<template>
	<om-formsub-outer :index="index" :checkedit="checkedit">
		<om-autoform ref="autoform" :edit="edit" :checkedit="checkedit" :initConfigData="autoformdata" :initValue="initValue"></om-autoform>
	</om-formsub-outer>
</template>

<script>
	import {
		buildSubFormData,
		subOnLoad,
		changeEditor,
		configSelectData
	} from '../../../static/js/formUtil.js';
	import {
		ignoreHtml,
		ptFloat,
		minusF,
		getDateStr
	} from '@/static/js/common.js';
	import urlUtil from '@/static/js/urlUtil.js';
	export default {
		provide() {
			return {
				formPage: this
			};
		},
		data() {
			return buildSubFormData({
				mainData:[]
			})
		},
		methods:{
			inputProjectNum(val){
				let _that = this
				if(_that.$refs.autoform.formdata.unitPriceIncludingTax){
					_that.$refs.autoform.formdata.priceIncludingTax = Number(_that.$refs.autoform.formdata.unitPriceIncludingTax) * Number(val)
				}
				if(_that.$refs.autoform.formdata.unitPriceWithoutTax){
					_that.$refs.autoform.formdata.taxFreeAmount = Number(_that.$refs.autoform.formdata.unitPriceWithoutTax) * Number(val)
				}
				
			},
			initload(){
				let _that = this
				let arr = [
					_that.om.request(
						'dictSource/loadCombo',
						{
							sourceId:'289',
							categoryId:'8158'
						}
					),
					_that.om.request(
						'dictSource/loadCombo',
						{
							sourceId:'289',
							categoryId:'7969'
						}
					)
				]
				Promise.all(arr).then(res=>{
					_that.$refs.autoform.changeEditor("title2","lclId","data",configSelectData(res[0],'id','text'))
					_that.$refs.autoform.initSelectIndex("title2",'lclId')
					_that.$refs.autoform.changeEditor("title2","spellTheId","data",configSelectData(res[1],'id','text'))
					_that.$refs.autoform.initSelectIndex("title2",'spellTheId')
				})
			},
			
		},
		onLoad(e) {
			let _that = this
			subOnLoad(_that, e, function() {
				if (e.configDataCacheKey) {
					uni.getStorage({
						key: e.configDataCacheKey,
						success: function(res) {
							//if (res.data && res.data instanceof Array) {
							if(res.data && Object.prototype.toString.call(res.data)==='[object Array]'){
								_that.autoformdata = res.data
							}
							Object.assign(_that.initValue, _that.formdata)
							_that.autoformdata[0].order = _that.order
							_that.initload()
						}
					})
				}
			})
		},
		onShow() {
			let _that = this
			if (_that.$refs.autoform) {
				
			}
		}
	}
</script>

<style>
</style>
